﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NorthwindSample.Data;
using Kendo.Mvc.UI;

namespace NorthwindSample.Controllers
{
    public class CustomersController : Controller
    {
        //
        // GET: /Customers/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult GetCustomers([DataSourceRequest] DataSourceRequest request)
        {
            var customers = CustomersRepository.GetCustomers().Select(c => new
            {
                CustomerID = c.CustomerID,
                CompanyName = c.CompanyName,
                ContactName = c.ContactName,
                ContactTitle = c.ContactTitle,
                Address = c.Address,
                City = c.City,
                Region = c.Region,
                PostalCode = c.PostalCode,
                Country = c.Country,
                Phone = c.Phone,
                Fax = c.Fax
            }).ToList();

            return Json(new DataSourceResult { Data = customers });
        }
    }
}
